package com.sikao.app.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.sikao.app.R;

/**
 * Created by y50 on 2016/4/28.
 */
public class PersonalCenterAdapter extends BaseAdapter{

	private Context context;
	private String[] titles;

	public PersonalCenterAdapter(Context context,String[] titles){
		this.context = context;
		this.titles = titles;
	}

	@Override
	public int getCount() {
		return titles.length;
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View view;
		ViewHolder holder;
		if(convertView == null){
			view = View.inflate(context,R.layout.personal_center_list_item,null);
			holder = new ViewHolder(view);
			view.setTag(holder);
		}else{
			view = convertView;
			holder = (ViewHolder) view.getTag();
		}
		if (position == 0){
			holder.view_line.setVisibility(View.GONE);
		}
		holder.tv.setText(titles[position]);
		return view;
	}

	public class ViewHolder {
		public final TextView tv;
		public final View root;
		public final View view_line;

		public ViewHolder(View root) {
			tv = (TextView) root.findViewById(R.id.tv);
			view_line = root.findViewById(R.id.view_line);
			this.root = root;
		}
	}
}
